package com.navcoo.yidaaddproapi.controller;

import cn.hutool.json.JSONObject;
import com.navcoo.yidaaddproapi.response.Result;
import com.navcoo.yidaaddproapi.service.DataSourceService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 数据源控制器
 *
 * @author Navcoo
 * @date 2024-04-30
 */
@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/data_source")
public class DataSourceController {

    private final DataSourceService dataSourceService;

    /**
     * 获取数据源数据
     *
     * @return {@link Result}<{@link JSONObject}>
     */
    @GetMapping("/get")
    private Result<List<JSONObject>> getDataSourceDatas(){
        return dataSourceService.getDataSourceDatas();
    }

    @GetMapping("/insert")
    private Result<Void> insertDataSourceDatas(){
        dataSourceService.insertDataSourceDatas();
        return Result.success();
    }
}
